package com.scott.condition;


import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

import java.lang.annotation.Annotation;

/**
 * 判断操作系统是否是Windows
 */
public class WindowsCondition implements Condition {

    /**
     *
     * @param context    判断条件使用的上下文环境
     * @param metadata   注释信息
     * @return
     */
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        //获取当前环境信息
        Environment environment = context.getEnvironment();
        String os = environment.getProperty("os.name");
        if(os.contains("Windows")){
            return true;
        }
        return false;
    }
}
